package main

import (
	"fmt"
)

func main() {
	//go语言只有一个循环关键字，支持多种循环方式
	//for init;cond;post
	//计算1+2+3+。。。+100
	sum := 0
	for i := 1; i <= 100; i++ {
		sum += i
	}
	fmt.Println(sum)
	// while(cond) ==> for cond
	sum = 0
	i := 1
	for i <= 100 {
		sum += i
		i++
	}
	fmt.Println(sum)
	//while(true) ===> for
	i = 0
	for {
		fmt.Println("who can kill me?")
		i++
		if i == 3 {
			break
		}
	}

	//打印 9*9 乘法口诀
	/*
		1*1 = 1
		1*2 = 2  2*2 = 4
		1*3 = 3  2*3 = 6 3*3 = 9
	*/
	for i := 1; i <= 9; i++ {
		for j := 1; j <= i; j++ {
			fmt.Printf("%d*%d = %d\t", j, i, j*i)
		}
		fmt.Println()
	}
}
